<%@ page import="sugarbind_input.*" %>

<html>
<head>

<g:javascript src="jquery-1.9.1.js"/>
<g:javascript src="jquery.validate.js"/>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main"/>
<title>Insert data</title>
	
	

</head>
<body>
	<div>  	
	<g:form method="GET" id="insertForm" name="insertForm" action ="save">
		<div>	
		<!-- REFERENCE -->
			<div class='nav' >
			(*) : mandatory field
			<br><hr><br>
			
			<br><h4>References</h4><br> 				
				<span class="menuButton">
			    <g:select name="article_Type" 
			          from="${sugarbind_input.Article_Type.listArticle_Types()}"			          
			          optionKey="id" 
			          noSelection="['':'Choose an Article_Type']"
			          onchange="${remoteFunction (
                        controller: 'article_Type',
                        action: 'findArticles',
                        params: '\'article_Type.id=\'+ this.value',
                        update: 'article')}"			         
			          />
			       <img src="${resource(dir:'images',file:'help.png')}" alt="" border="0" height="25" title="Articles can be filtered by selecting an article type"/>
			      			     
			      <g:submitToRemote id="reloadArticleTypes" class="refresh"
			      		controller="article_Type"
                        action="findArticle_Types"
                        update="article_Type"
                        method="GET"                                                               
                                                               
					/>
						
			        
			          
			          <g:link controller="article_Type" class="create" action="create" target="_new"  style="width:15%;">
			        	New article type
			    		</g:link>
			    		
			    	</span> 
		 		
		 		<br>
			
			
		    	<span class="menuButton">
		    	
		      	(*) 
			    <g:select name ="article" required="true"
			    		from="${sugarbind_input.Article.listArticles()}"
			    		optionKey="id" 
			   			noSelection="['':'Choose an Article']"
			    />
			    <g:submitToRemote id="reloadArticles" class="refresh"
			      		controller="article"
                        action="findArticles"                        
                        update="article"
                        method="GET"                                                               
					/>
			    			  
		         	<g:link controller="article" class="create" action="create" target="_new"  style="width:15%;">
		        	New article
		    		</g:link>
		 		</span>
		 		<br>
		 		
		    
		      <span>
		      <g:select name="author"
			          from="${sugarbind_input.Author.listAuthors()}"
			          optionKey="id" 
			          noSelection="['':'Choose multiple Authors']"
			          multiple="true"
			          /> 
			  <g:submitToRemote id="reloadAuthors" class="refresh"
			      		controller="author"
                        action="findAuthors"
                        update="author"
                        method="GET"                                                                                                                              
					/>        
		        <g:link controller="author" class="create" action="create" target="_new"  style="width:15%;">
		          New author
		        </g:link>
		      </span>
		      
		      <br><hr>
		      
		    <!-- AGENT -->
		    <br><h4>Agent</h4><br> 
	  			<span class="menuButton">
		          
			      <g:select name="agent_Type" 
			          from="${sugarbind_input.Agent_Type.listAgent_Types()}"
			          optionKey="id" 
			          noSelection="['':'Choose an Agent_Type']"
			          onchange="${remoteFunction (
                        controller: 'agent_Type',
                        action: 'findAgents',
                        params: '\'agent_Type.id=\'+ this.value',
                        update: 'agent')}"			         
			          />
			      <img src="${resource(dir:'images',file:'help.png')}" alt="" border="0" height="25" title="Agents can be filtered by selecting an agent type"/>     			          
		          <g:submitToRemote id="reloadAgent_Types" class="refresh"
			      		controller="agent_Type"
                        action="findAgent_Types"
                        update="agent_Type"
                        method="GET"                                                                                                                              
					/> 
		          
		          <g:link controller="agent_Type" class="create" action="create" target="_new"  style="width:15%;">
		            New agent type
		          </g:link>
		        </span>
		        <br>
		        
		        <span class="menuButton">
		        
		        <g:select name="agent" 
		        	from="${sugarbind_input.Agent.listAgents()}"
		        	optionKey="id" 
		        	noSelection="['':'Choose an Agent']"
		        	onchange="${remoteFunction (
                     controller: 'agent',
                     action: 'findLectin_Supports',
                     params: '\'agent.id=\'+ this.value',
                     update: 'lectin_Support')}"
                />			
                <img src="${resource(dir:'images',file:'help.png')}" alt="" border="0" height="25" title="Lectin supports can be filtered by selecting an agent"/>     			          		        
		        <g:submitToRemote id="reloadAgents" class="refresh"
			      		controller="agent"
                        action="findAgents"
                        update="agent"
                        method="GET"                                                                                                                              
					/>      
		                
		          <g:link controller="agent" class="create" action="create" target="_new" style="width:15%;">
		            New agent
		          </g:link>
		        </span>
		        <br>		        		         
		        
		    <br><hr>
		    <!-- LECTIN AND SUPPORT -->
		    <br><h4>Lectin and support</h4><br> 
		    
		    <!-- 
	  			<span class="menuButton">
		          <g:select name="lectin_Support_Type"
			          from="${sugarbind_input.Lectin_Support_Type.listOrderByLectin_Support_Type_Name()}"
			          noSelection="['':'Choose a Lectin_Support_Type']"
			          optionKey="id" 
			          />
		          <g:link controller="lectin_Support_Type" class="create" action="create" target="_new" style="width:20%;">
		            New lectin support type
		          </g:link>
		        </span>
		        <br>
		       --> 
		        
		        <span class="menuButton">		       
		        	<g:select name ="lectin_Support" 
				        	from="${sugarbind_input.Lectin_Support.listLectin_Supports()}"
				        	optionKey="id" 
				        	noSelection="['':'Choose a Lectin_Support']"
				        	onchange="${remoteFunction (
			                     controller: 'lectin_Support',
			                     action: 'findLectins',
			                     params: '\'lectin_Support.id=\'+ this.value',
			                     update: 'lectin')}"
				        	
			    	/>
		      		<img src="${resource(dir:'images',file:'help.png')}" alt="" border="0" height="25" title="Lectins can be filtered by selecting a lectin support"/>    
		           <g:submitToRemote id="reloadLectin_Supports" class="refresh"
			      		controller="lectin_Support"
                        action="findLectin_Supports"
                        update="lectin_Support"
                        method="GET"                                                                                                                              
					/>
					   
		          <g:link controller="lectin_Support" class="create" action="create" target="_new" style="width:20%;">
		            New lectin support
		          </g:link>
		        </span>
		    	<br>
		        
		        <span class="menuButton">
		        (*)
		          <g:select name="lectin"  required="true"
			          from="${sugarbind_input.Lectin.listLectins()}"
			          optionKey="id" 
				      noSelection="['':'Choose a Lectin']"
			          />
			      <g:submitToRemote id="reloadLectins" class="refresh"
			      		controller="lectin"
                        action="findLectins"
                        update="lectin"
                        method="GET"                                                                                                                              
					/>    
		          <g:link controller="lectin" class="create" action="create" target="_new" style="width:15%;">
		            New lectin
		          </g:link>
		        </span>
		        <br>


		    <br><hr>
		    	
		  	<!-- LIGAND -->
	  		<br><h4>Ligand</h4><br> 
	  			<span class="menuButton">
	  			
		          <g:select name="structure" 
			          from="${sugarbind_input.Structure.listStructures()}"
			          optionKey="id" 
				      noSelection="['':'Choose a Structure']"
				      onchange="${remoteFunction (
			                     controller: 'structure',
			                     action: 'findLigands',
			                     params: '\'structure.id=\'+ this.value',
			                     update: 'ligand')}"			          
			      />
			      <img src="${resource(dir:'images',file:'help.png')}" alt="" border="0" height="25" title="Ligands can be filtered by selecting a glycan structure"/>
			      <g:submitToRemote id="reloadStructures" class="refresh"
			      		controller="structure"
                        action="findStructures"
                        update="structure"
                        method="GET"                                                                                                                              
					/>
					
		          <g:link controller="structure" class="create" action="create" target="_new" style="width:15%;">
		            New structure
		          </g:link>
		        </span>
	  		<br>		        
		        
	  			<span class="menuButton">
	  			(*)
		          <g:select name="ligand"  required="true"
			          from="${sugarbind_input.Ligand.listLigands(); }"
			          optionKey="id" 
			          noSelection="['':'Choose a Ligand']"
			          /> 
			      <g:submitToRemote id="reloadLigands" class="refresh"
			      		controller="ligand"
                        action="findLigands"
                        update="ligand"
                        method="GET"                                                                                                                              
					/>    
		          <g:link controller="ligand" class="create" action="create" target="_new" style="width:15%;">
		            New ligand
		          </g:link>		         
		        </span>
		        <br>
		        
		  
		        	   		     
		      <br><hr>	
		      
		      
		       <!-- LIGAND SOURCE-->
	  		<br><h4>Ligand sources</h4><br> 
	  			<span class="menuButton">
		          <g:select name="source"
			          from="${sugarbind_input.Source.listSources(); }"
			          optionKey="id" 
			          noSelection="['':'Choose multiple Sources']"
			          multiple="true"/>
			          
			      <g:submitToRemote id="reloadSources" class="refresh"
			      		controller="source"
                        action="findSources"
                        update="source"
                        method="GET"                                                                                                                              
					/>       
		          <g:link controller="source" class="create" action="create" target="_new" style="width:15%;">
		            New ligand source
		          </g:link>
		        </span>
		      	<br><hr>
		      	
		      	
		      <!-- BINDING -->
		      <br><h4>Binding</h4><br>		      		    
		        
		        <span class="menuButton">
		          <g:select name="binding_Strength"
			          from="${sugarbind_input.Binding_Strength.listBinding_Strengths()}"
			          optionKey="id"
			          noSelection="['':'Choose a Binding_Strength']" 
			          />
			      <g:submitToRemote id="reloadBinding_Strengths" class="refresh"
			      		controller="binding_Strength"
                        action="findBinding_Strengths"
                        update="binding_Strength"
                        method="GET"                                                                                                                              
					/>    
		          <g:link controller="binding_Strength" class="create" action="create" target="_new" style="width:15%;">
		            New Binding strength
		          </g:link>
		        </span>
		        <br>
		        
		        <span class="menuButton">
		          <g:select name="method"
			          from="${sugarbind_input.Method.listMethods()}"
			          noSelection="['':'Choose multiple Methods']"
			          optionKey="id" 
			          multiple="true"
			          />
			      <g:submitToRemote id="reloadMethods" class="refresh"
			      		controller="method"
                        action="findMethods"
                        update="method"
                        method="GET"                                                                                                                              
					/>    
		          <g:link controller="method" class="create" action="create" target="_new" style="width:15%;">
		            New Method
		          </g:link>
		        </span>
		      <br><hr>
		      
		      
		      <!-- AREA -->
		      <br><h4>Affected area</h4><br> 
		      		      
		        
	  			<span class="menuButton">
		          <g:select name="area"
			          from="${sugarbind_input.Area.listAreas(); }"
			          noSelection="['':'Choose multiple Areas']"
			          multiple="true"
			          optionKey="id" 
			          /> 
			      <g:submitToRemote id="reloadAreas" class="refresh"
			      		controller="area"
                        action="findAreas"
                        update="area"
                        method="GET"                                                                                                                              
					/>     
		          <g:link controller="area" class="create" action="create" target="_new" style="width:15%;">
		            New area
		          </g:link>
		        </span>
		      <br><hr>
		      

		     <!-- DISEASE -->
		     <br><h4>Disease</h4><br> 
	  			<span class="menuButton">
		          <g:select name="disease"
			          from="${sugarbind_input.Disease.listDiseases()}"
			          noSelection="['':'Choose multiple Diseases']"
			          optionKey="id" 
			          multiple="true"/>
			          
			      <g:submitToRemote id="reloadDiseases" class="refresh"
			      		controller="disease"
                        action="findDiseases"
                        update="disease"
                        method="GET"                                                                                                                              
					/>        
		          <g:link controller="disease" class="create" action="create" target="_new" style="width:15%;">
		            New disease
		          </g:link>
		        </span>
		        <br>
		      	    
		  	</div>
		  	
		</div>
	
		<hr>
		<span>						
			<div class="buttons">
			<br>
				<span class="button"><g:actionSubmit 
						value=" SAVE " action="save" /> </span>
			<br><br>
			</div>
		</span>		
		</g:form>
		<script type="text/javascript"> 	
			$("#insertForm").validate({
		        rules: {
			        article : "required",
<%--			        agent : "required",--%>
			        lectin : "required",
			        ligand : "required"

			        },
			    messages: {
			    	article : "Select an Article",
<%--			        agent : "Select an Agent",--%>
			        lectin : "Select a Lectin",
			        ligand : "Select a Ligand"
			    }   
	        }
			);

		</script>
		
	</div>
</body>
</html>
